package com.com.datastructures.stack;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Ngo Lap Thanh
 * Date: 23/05/14
 * Time: 3:18 PM
 * To change this template use File | Settings | File Templates.
 */
public class Stack2<T> {

    List<T> stack;

    public Stack2(){
       stack = new ArrayList<T>();
    }

    public void push(T t){
        stack.add(t);
    }

    public T pop() {

        T t =  stack.get(stack.size()-1);
        stack.remove(stack.get(stack.size()-1));
        return t;
    }

    public T peek() {
        return stack.get(stack.size()-1);
    }
}


